package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

/*静态文件处理,需要
Administrator@c2b MINGW64 ~/go/src/github.com/tongbonb/gin_test_project/router_static
$ go build -o route_static
$ ./route_static
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /assets/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] HEAD   /assets/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] GET    /static/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] HEAD   /static/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default
[GIN-debug] Listening and serving HTTP on :8080
 可以通过
http://localhost:8080/assets/hello.html
http://localhost:8080/static/hello.html
http://localhost:8080/favicon.ico
*/

func main() {
	r := gin.Default()
	r.Static("/assets","./assets")
	//另外两种,见名知意
	r.StaticFS("/static",http.Dir("static"))
	r.StaticFile("/favicon.ico","./favicon.ico")


	r.Run()
}
